package com.tsystems.train.bean;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.tsystems.train.entity.Station;

public class StationTableDataModel extends ListDataModel<Station> implements
		SelectableDataModel<Station>, Serializable {

	

	
	private static final long serialVersionUID = 3170725918988239610L;

	public StationTableDataModel() {
	}

	public StationTableDataModel(List<Station> data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	public Station getRowData(String rowKey) {
		List<Station> stations = (List<Station>) getWrappedData();

		for (Station station : stations) {
			String key = station.getName();
			if (key.equals(rowKey))
				return station;
		}

		return null;
	}

	public Object getRowKey(Station station) {
		return station.getName();
	}
}
